package designpattern.simplefactory.commodity;

/**
 * 使用反射机制来获取商品实例
 */
public class CommodityFactoryReflection {
    public static ICommodity getCommodityInstance(Class<? extends ICommodity> clazz) {
        try {
            if (null != clazz) {
                return clazz.newInstance();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
